package com.qf.web;

import com.qf.pojo.User;
import com.qf.service.UserService;
import com.qf.service.serviceimpl.UserServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
 * 通过id查找用户
 * */
@WebServlet("/findByIdServlet")
public class FindByIdServlet extends HttpServlet {
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");//设置post接受请求乱码
        response.setContentType("text/html;charset=utf-8");//设置响应乱码
        String uid = request.getParameter("uid");//获取uid
        UserService us = new UserServiceImpl();
        User user1 = us.findById(uid);
        if(user1 != null){
            request.setAttribute("user1",user1);
            request.getRequestDispatcher("/admin/modify.jsp").forward(request,response);
        }
    }

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }
}
